package cn.liasoux.Consumer;

import cn.hutool.json.JSONUtil;
import cn.liasoux.common.Mail;
import cn.liasoux.utils.MailUtil;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class Consumer {


    @Value("${spring.rabbitmq.mail.router}")
    private String MAIL_ROUTER_KEY;




    public static final String xxx = "mail.queue";

    @Autowired
    MailUtil mailUtil;

    @RabbitListener(queues = "mail.queue")
    @RabbitHandler
    public void emailConsumer(String mailJson){
        mailUtil.send(JSONUtil.toBean(mailJson, Mail.class));
    }
}
